
<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <meta charset="utf-8" />
    <title>bdsim package &#8212; Block diagram simulation 0.7 documentation</title>
    <link rel="stylesheet" href="_static/alabaster.css" type="text/css" />
    <link rel="stylesheet" href="_static/pygments.css" type="text/css" />
    <link rel="stylesheet" type="text/css" href="_static/graphviz.css" />
    <script id="documentation_options" data-url_root="./" src="_static/documentation_options.js"></script>
    <script src="_static/jquery.js"></script>
    <script src="_static/underscore.js"></script>
    <script src="_static/doctools.js"></script>
    <script src="_static/language_data.js"></script>
    <script async="async" src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/latest.js?config=TeX-AMS-MML_HTMLorMML"></script>
    <link rel="index" title="Index" href="genindex.html" />
    <link rel="search" title="Search" href="search.html" />
    <link rel="next" title="Blocks" href="bdsim.blocks.html" />
    <link rel="prev" title="Block diagram simulator" href="index.html" />
   
  <link rel="stylesheet" href="_static/custom.css" type="text/css" />
  
  
  <meta name="viewport" content="width=device-width, initial-scale=0.9, maximum-scale=0.9" />

  </head><body>
  

    <div class="document">
      <div class="documentwrapper">
        <div class="bodywrapper">
          

          <div class="body" role="main">
            
  <div class="section" id="bdsim-package">
<h1>bdsim package<a class="headerlink" href="#bdsim-package" title="Permalink to this headline">¶</a></h1>
<div class="section" id="module-bdsim.blockdiagram">
<span id="blockdiagram-class"></span><h2>BlockDiagram class<a class="headerlink" href="#module-bdsim.blockdiagram" title="Permalink to this headline">¶</a></h2>
<p>Created on Mon May 18 21:43:18 2020</p>
<p>&#64;author: corkep</p>
<dl class="class">
<dt id="bdsim.blockdiagram.BlockDiagram">
<em class="property">class </em><code class="sig-prename descclassname">bdsim.blockdiagram.</code><code class="sig-name descname">BlockDiagram</code><span class="sig-paren">(</span><em class="sig-param">name='main'</em>, <em class="sig-param">**kwargs</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/bdsim/blockdiagram.html#BlockDiagram"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#bdsim.blockdiagram.BlockDiagram" title="Permalink to this definition">¶</a></dt>
<dd><p>Bases: <code class="xref py py-class docutils literal notranslate"><span class="pre">object</span></code></p>
<p>Block diagram class.  This object is the parent of all blocks and wires in 
the system.</p>
<dl class="field-list simple">
<dt class="field-odd">Variables</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>wirelist</strong> (<em>list of Wire instances</em>) – all wires in the diagram</p></li>
<li><p><strong>blocklist</strong> (<em>list of Block subclass instances</em>) – all blocks in the diagram</p></li>
<li><p><strong>x</strong> (<em>np.ndarray</em>) – state vector</p></li>
<li><p><strong>compiled</strong> (<em>bool</em>) – diagram has successfully compiled</p></li>
<li><p><strong>T</strong> (<em>float</em>) – maximum simulation time (seconds)</p></li>
<li><p><strong>t</strong> (<em>float</em>) – current simulation time (seconds)</p></li>
<li><p><strong>fignum</strong> (<em>int</em>) – number of next matplotlib figure to create</p></li>
<li><p><strong>stop</strong> (<em>Block subclass</em>) – reference to block wanting to stop simulation, else None</p></li>
<li><p><strong>checkfinite</strong> (<em>bool</em>) – halt simulation if any wire has inf or nan</p></li>
<li><p><strong>blockcounter</strong> (<em>collections.Counter</em>) – unique counter for each block type</p></li>
<li><p><strong>blockdict</strong> (<em>dict of lists</em>) – index of all blocks by category</p></li>
<li><p><strong>name</strong> (<em>str</em>) – name of this diagram</p></li>
<li><p><strong>graphics</strong> (<em>bool</em>) – enable graphics</p></li>
</ul>
</dd>
</dl>
<dl class="method">
<dt id="bdsim.blockdiagram.BlockDiagram.add_block">
<code class="sig-name descname">add_block</code><span class="sig-paren">(</span><em class="sig-param">block</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/bdsim/blockdiagram.html#BlockDiagram.add_block"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#bdsim.blockdiagram.BlockDiagram.add_block" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="method">
<dt id="bdsim.blockdiagram.BlockDiagram.add_wire">
<code class="sig-name descname">add_wire</code><span class="sig-paren">(</span><em class="sig-param">wire</em>, <em class="sig-param">name=None</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/bdsim/blockdiagram.html#BlockDiagram.add_wire"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#bdsim.blockdiagram.BlockDiagram.add_wire" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="method">
<dt id="bdsim.blockdiagram.BlockDiagram.blockvalues">
<code class="sig-name descname">blockvalues</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="_modules/bdsim/blockdiagram.html#BlockDiagram.blockvalues"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#bdsim.blockdiagram.BlockDiagram.blockvalues" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="method">
<dt id="bdsim.blockdiagram.BlockDiagram.compile">
<code class="sig-name descname">compile</code><span class="sig-paren">(</span><em class="sig-param">subsystem=False</em>, <em class="sig-param">doimport=True</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/bdsim/blockdiagram.html#BlockDiagram.compile"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#bdsim.blockdiagram.BlockDiagram.compile" title="Permalink to this definition">¶</a></dt>
<dd><p>Compile the block diagram</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>subsystem</strong> (<em>bool</em><em>, </em><em>optional</em>) – importing a subsystems, defaults to False</p></li>
<li><p><strong>doimport</strong> (<em>bool</em><em>, </em><em>optional</em>) – import subsystems, defaults to True</p></li>
</ul>
</dd>
<dt class="field-even">Raises</dt>
<dd class="field-even"><p><strong>RuntimeError</strong> – various block diagram errors</p>
</dd>
<dt class="field-odd">Returns</dt>
<dd class="field-odd"><p>Compile status</p>
</dd>
<dt class="field-even">Return type</dt>
<dd class="field-even"><p>bool</p>
</dd>
</dl>
<p>Performs a number of operations:</p>
<blockquote>
<div><ul class="simple">
<li><p>Check sanity of block parameters</p></li>
<li><p>Recursively clone and import subsystems</p></li>
<li><p>Check for loops without dynamics</p></li>
<li><p>Check for inputs driven by more than one wire</p></li>
<li><p>Check for unconnected inputs and outputs</p></li>
<li><p>Link all output ports to outgoing wires</p></li>
<li><p>Link all input ports to incoming wires</p></li>
<li><p>Evaluate all blocks in the network</p></li>
</ul>
</div></blockquote>
</dd></dl>

<dl class="method">
<dt id="bdsim.blockdiagram.BlockDiagram.connect">
<code class="sig-name descname">connect</code><span class="sig-paren">(</span><em class="sig-param">*args</em>, <em class="sig-param">name=None</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/bdsim/blockdiagram.html#BlockDiagram.connect"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#bdsim.blockdiagram.BlockDiagram.connect" title="Permalink to this definition">¶</a></dt>
<dd><dl class="simple">
<dt>TODO:</dt><dd><p>s.connect(out[3], in1[2], in2[3])  # one to many
block[1] = SigGen()  # use setitem
block[1] = SumJunction(block2[3], block3[4]) * Gain(value=2)</p>
</dd>
</dl>
</dd></dl>

<dl class="method">
<dt id="bdsim.blockdiagram.BlockDiagram.create_figure">
<code class="sig-name descname">create_figure</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="_modules/bdsim/blockdiagram.html#BlockDiagram.create_figure"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#bdsim.blockdiagram.BlockDiagram.create_figure" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="method">
<dt id="bdsim.blockdiagram.BlockDiagram.done">
<code class="sig-name descname">done</code><span class="sig-paren">(</span><em class="sig-param">**kwargs</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/bdsim/blockdiagram.html#BlockDiagram.done"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#bdsim.blockdiagram.BlockDiagram.done" title="Permalink to this definition">¶</a></dt>
<dd><p>Inform all active blocks that.BlockDiagram is complete.  Close files,
graphics, etc.</p>
<p>Invokes the <cite>done</cite> method on all blocks.</p>
</dd></dl>

<dl class="method">
<dt id="bdsim.blockdiagram.BlockDiagram.dotfile">
<code class="sig-name descname">dotfile</code><span class="sig-paren">(</span><em class="sig-param">file</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/bdsim/blockdiagram.html#BlockDiagram.dotfile"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#bdsim.blockdiagram.BlockDiagram.dotfile" title="Permalink to this definition">¶</a></dt>
<dd><p>Write a GraphViz dot file representing the network.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><p><strong>file</strong> (<em>str</em>) – Name of file to write to</p>
</dd>
</dl>
<p>The file can be processed using neato or dot:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="o">%</span> <span class="n">dot</span> <span class="o">-</span><span class="n">Tpng</span> <span class="o">-</span><span class="n">o</span> <span class="n">out</span><span class="o">.</span><span class="n">png</span> <span class="n">dotfile</span><span class="o">.</span><span class="n">dot</span>
</pre></div>
</div>
</dd></dl>

<dl class="method">
<dt id="bdsim.blockdiagram.BlockDiagram.evaluate">
<code class="sig-name descname">evaluate</code><span class="sig-paren">(</span><em class="sig-param">x</em>, <em class="sig-param">t</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/bdsim/blockdiagram.html#BlockDiagram.evaluate"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#bdsim.blockdiagram.BlockDiagram.evaluate" title="Permalink to this definition">¶</a></dt>
<dd><p>Evaluate all blocks in the network</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>x</strong> (<em>numpy.ndarray</em>) – state</p></li>
<li><p><strong>t</strong> (<em>float</em>) – current time</p></li>
</ul>
</dd>
<dt class="field-even">Returns</dt>
<dd class="field-even"><p>state derivative</p>
</dd>
<dt class="field-odd">Return type</dt>
<dd class="field-odd"><p>numpy.ndarray</p>
</dd>
</dl>
<p>Performs the following steps:</p>
<ol class="arabic simple">
<li><p>Partition the state vector to all stateful blocks</p></li>
<li><p>Propogate known block output ports to connected input ports</p></li>
</ol>
</dd></dl>

<dl class="method">
<dt id="bdsim.blockdiagram.BlockDiagram.getstate">
<code class="sig-name descname">getstate</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="_modules/bdsim/blockdiagram.html#BlockDiagram.getstate"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#bdsim.blockdiagram.BlockDiagram.getstate" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="method">
<dt id="bdsim.blockdiagram.BlockDiagram.ls">
<code class="sig-name descname">ls</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="_modules/bdsim/blockdiagram.html#BlockDiagram.ls"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#bdsim.blockdiagram.BlockDiagram.ls" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="method">
<dt id="bdsim.blockdiagram.BlockDiagram.report">
<code class="sig-name descname">report</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="_modules/bdsim/blockdiagram.html#BlockDiagram.report"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#bdsim.blockdiagram.BlockDiagram.report" title="Permalink to this definition">¶</a></dt>
<dd><p>Print a tabular report about the block diagram</p>
</dd></dl>

<dl class="method">
<dt id="bdsim.blockdiagram.BlockDiagram.reset">
<code class="sig-name descname">reset</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="_modules/bdsim/blockdiagram.html#BlockDiagram.reset"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#bdsim.blockdiagram.BlockDiagram.reset" title="Permalink to this definition">¶</a></dt>
<dd><p>Reset conditions within every active block.  Most importantly, all
inputs are marked as unknown.</p>
<p>Invokes the <cite>reset</cite> method on all blocks.</p>
</dd></dl>

<dl class="method">
<dt id="bdsim.blockdiagram.BlockDiagram.run">
<code class="sig-name descname">run</code><span class="sig-paren">(</span><em class="sig-param">T=10.0</em>, <em class="sig-param">dt=0.1</em>, <em class="sig-param">solver='RK45'</em>, <em class="sig-param">block=False</em>, <em class="sig-param">checkfinite=True</em>, <em class="sig-param">watch=[]</em>, <em class="sig-param">**kwargs</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/bdsim/blockdiagram.html#BlockDiagram.run"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#bdsim.blockdiagram.BlockDiagram.run" title="Permalink to this definition">¶</a></dt>
<dd><p>Run the block diagram</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>T</strong> (<em>float</em><em>, </em><em>optional</em>) – maximum integration time, defaults to 10.0</p></li>
<li><p><strong>dt</strong> (<em>float</em><em>, </em><em>optional</em>) – maximum time step, defaults to 0.1</p></li>
<li><p><strong>solver</strong> (<em>str</em><em>, </em><em>optional</em>) – integration method, defaults to <code class="docutils literal notranslate"><span class="pre">RK45</span></code></p></li>
<li><p><strong>block</strong> (<em>bool</em>) – matplotlib block at end of run, default False</p></li>
<li><p><strong>checkfinite</strong> (<em>bool</em>) – error if inf or nan on any wire, default True</p></li>
<li><p><strong>watch</strong> (<em>list</em>) – list of input ports to log</p></li>
<li><p><strong>**kwargs</strong> – passed to <code class="docutils literal notranslate"><span class="pre">scipy.integrate</span></code></p></li>
</ul>
</dd>
<dt class="field-even">Returns</dt>
<dd class="field-even"><p>time history of signals and states</p>
</dd>
<dt class="field-odd">Return type</dt>
<dd class="field-odd"><p>Sim class</p>
</dd>
</dl>
<p>Assumes that the network has been compiled.</p>
<p>Graphics display in all blocks can be disabled using the <cite>graphics</cite>
option to the <code class="docutils literal notranslate"><span class="pre">BlockDiagram</span></code> instance.</p>
<p>Results are returned in a class with attributes:</p>
<ul class="simple">
<li><p><code class="docutils literal notranslate"><span class="pre">t</span></code> the time vector: ndarray, shape=(M,)</p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">x</span></code> is the state vector: ndarray, shape=(M,N)</p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">xnames</span></code> is a list of the names of the states corresponding to columns of <cite>x</cite>, eg. “plant.x0”,
defined for the block using the <code class="docutils literal notranslate"><span class="pre">snames</span></code> argument</p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">uN'`</span> <span class="pre">for</span> <span class="pre">a</span> <span class="pre">watched</span> <span class="pre">input</span> <span class="pre">where</span> <span class="pre">N</span> <span class="pre">is</span> <span class="pre">the</span> <span class="pre">index</span> <span class="pre">of</span> <span class="pre">the</span> <span class="pre">port</span> <span class="pre">mentioned</span> <span class="pre">in</span> <span class="pre">the</span> <span class="pre">``watch</span></code> argument</p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">unames</span></code> is a list of the names of the input ports being watched, same order as in <code class="docutils literal notranslate"><span class="pre">watch</span></code> argument</p></li>
</ul>
<p>If there are no dynamic elements in the diagram, ie. no states, then <code class="docutils literal notranslate"><span class="pre">x</span></code> and <code class="docutils literal notranslate"><span class="pre">xnames</span></code> are not
present.</p>
<p>The <code class="docutils literal notranslate"><span class="pre">watch</span></code> argument is a list of one or more input ports whose value during simulation
will be recorded.  The elements of the list can be:</p>
<blockquote>
<div><ul class="simple">
<li><p>a <code class="docutils literal notranslate"><span class="pre">Block</span></code> reference, which is interpretted as input port 0</p></li>
<li><p>a <code class="docutils literal notranslate"><span class="pre">Plug</span></code> reference, ie. a block with an index or attribute</p></li>
<li><p>a string of the form “block[i]” which is port i of the block named block.</p></li>
</ul>
</div></blockquote>
</dd></dl>

<dl class="method">
<dt id="bdsim.blockdiagram.BlockDiagram.savefig">
<code class="sig-name descname">savefig</code><span class="sig-paren">(</span><em class="sig-param">format='pdf'</em>, <em class="sig-param">**kwargs</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/bdsim/blockdiagram.html#BlockDiagram.savefig"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#bdsim.blockdiagram.BlockDiagram.savefig" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="method">
<dt id="bdsim.blockdiagram.BlockDiagram.start">
<code class="sig-name descname">start</code><span class="sig-paren">(</span><em class="sig-param">**kwargs</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/bdsim/blockdiagram.html#BlockDiagram.start"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#bdsim.blockdiagram.BlockDiagram.start" title="Permalink to this definition">¶</a></dt>
<dd><p>Inform all active blocks that.BlockDiagram is about to start.  Open files,
initialize graphics, etc.</p>
<p>Invokes the <cite>start</cite> method on all blocks.</p>
</dd></dl>

<dl class="method">
<dt id="bdsim.blockdiagram.BlockDiagram.step">
<code class="sig-name descname">step</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="_modules/bdsim/blockdiagram.html#BlockDiagram.step"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#bdsim.blockdiagram.BlockDiagram.step" title="Permalink to this definition">¶</a></dt>
<dd><p>Tell all blocks to take action on new inputs.  Relevant to Sink
blocks only since they have no output function to be called.</p>
</dd></dl>

</dd></dl>

<dl class="function">
<dt id="bdsim.blockdiagram.DEBUG">
<code class="sig-prename descclassname">bdsim.blockdiagram.</code><code class="sig-name descname">DEBUG</code><span class="sig-paren">(</span><em class="sig-param">debug</em>, <em class="sig-param">*args</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/bdsim/blockdiagram.html#DEBUG"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#bdsim.blockdiagram.DEBUG" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="function">
<dt id="bdsim.blockdiagram.blockname">
<code class="sig-prename descclassname">bdsim.blockdiagram.</code><code class="sig-name descname">blockname</code><span class="sig-paren">(</span><em class="sig-param">cls</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/bdsim/blockdiagram.html#blockname"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#bdsim.blockdiagram.blockname" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="function">
<dt id="bdsim.blockdiagram.printProgressBar">
<code class="sig-prename descclassname">bdsim.blockdiagram.</code><code class="sig-name descname">printProgressBar</code><span class="sig-paren">(</span><em class="sig-param">fraction</em>, <em class="sig-param">prefix=''</em>, <em class="sig-param">suffix=''</em>, <em class="sig-param">decimals=1</em>, <em class="sig-param">length=50</em>, <em class="sig-param">fill='█'</em>, <em class="sig-param">printEnd='\r'</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/bdsim/blockdiagram.html#printProgressBar"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#bdsim.blockdiagram.printProgressBar" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

</div>
<div class="section" id="components">
<h2>Components<a class="headerlink" href="#components" title="Permalink to this headline">¶</a></h2>
<div class="graphviz"><img src="_images/inheritance-596710a430e4737f2cb3e9ac99e4c97022aafe16.png" alt="Inheritance diagram of bdsim.components" usemap="#inheritancefad3a12bf5" class="inheritance graphviz" /></div>
<map id="inheritancefad3a12bf5" name="inheritancefad3a12bf5">
<area shape="rect" id="node1" href="#bdsim.components.Block" target="_top" title="Construct a new block object." alt="" coords="3,138,96,152"/>
<area shape="rect" id="node2" href="#bdsim.components.FunctionBlock" target="_top" title="A FunctionBlock is a subclass of Block that represents a block that has inputs" alt="" coords="127,84,248,98"/>
<area shape="rect" id="node4" href="#bdsim.components.SinkBlock" target="_top" title="A SinkBlock is a subclass of Block that represents a block that has inputs" alt="" coords="133,111,241,125"/>
<area shape="rect" id="node6" href="#bdsim.components.SourceBlock" target="_top" title="A SourceBlock is a subclass of Block that represents a block that has outputs" alt="" coords="129,138,245,152"/>
<area shape="rect" id="node9" href="#bdsim.components.SubsystemBlock" target="_top" title="A Function is a subclass of Block that represents a block that has inputs" alt="" coords="123,165,252,179"/>
<area shape="rect" id="node10" href="#bdsim.components.TransferBlock" target="_top" title="A TransferBlock is a subclass of Block that represents a block with inputs" alt="" coords="127,192,247,206"/>
<area shape="rect" id="node3" href="#bdsim.components.GraphicsBlock" target="_top" title="A GraphicsBlock is a subclass of SinkBlock that represents a block that has inputs" alt="" coords="278,111,400,125"/>
<area shape="rect" id="node5" href="#bdsim.components.Plug" target="_top" title="Create a plug." alt="" coords="5,111,94,125"/>
<area shape="rect" id="node7" href="#bdsim.components.Struct" target="_top" title="A dict like object that allows items to be added by attribute or by key." alt="" coords="671,57,765,71"/>
<area shape="rect" id="node11" href="#bdsim.components.Wire" target="_top" title="Create a wire." alt="" coords="4,3,95,17"/>
</map><span class="target" id="module-bdsim.components"></span><p>Components of the simulation system, namely blocks, wires and plugs.</p>
<dl class="class">
<dt id="bdsim.components.Block">
<em class="property">class </em><code class="sig-prename descclassname">bdsim.components.</code><code class="sig-name descname">Block</code><span class="sig-paren">(</span><em class="sig-param">name=None</em>, <em class="sig-param">inames=None</em>, <em class="sig-param">onames=None</em>, <em class="sig-param">snames=None</em>, <em class="sig-param">pos=None</em>, <em class="sig-param">nin=None</em>, <em class="sig-param">nout=None</em>, <em class="sig-param">inputs=None</em>, <em class="sig-param">bd=None</em>, <em class="sig-param">**kwargs</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/bdsim/components.html#Block"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#bdsim.components.Block" title="Permalink to this definition">¶</a></dt>
<dd><p>Bases: <code class="xref py py-class docutils literal notranslate"><span class="pre">object</span></code></p>
<p>Construct a new block object.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>name</strong> (<em>str</em><em>, </em><em>optional</em>) – Name of the block, defaults to None</p></li>
<li><p><strong>inames</strong> (<em>list of str</em><em>, </em><em>optional</em>) – Names of input ports, defaults to None</p></li>
<li><p><strong>onames</strong> (<em>list of str</em><em>, </em><em>optional</em>) – Names of output ports, defaults to None</p></li>
<li><p><strong>snames</strong> (<em>list of str</em><em>, </em><em>optional</em>) – Names of states, defaults to None</p></li>
<li><p><strong>pos</strong> (<em>2-element tuple</em><em> or </em><em>list</em><em>, </em><em>optional</em>) – Position of block on the canvas, defaults to None</p></li>
<li><p><strong>bd</strong> (<a class="reference internal" href="#bdsim.blockdiagram.BlockDiagram" title="bdsim.blockdiagram.BlockDiagram"><em>BlockDiagram</em></a><em>, </em><em>optional</em>) – Parent block diagram, defaults to None</p></li>
<li><p><strong>nin</strong> (<em>int</em><em>, </em><em>optional</em>) – Number of inputs, defaults to None</p></li>
<li><p><strong>nout</strong> (<em>int</em><em>, </em><em>optional</em>) – Number of outputs, defaults to None</p></li>
<li><p><strong>*inputs</strong> (<a class="reference internal" href="#bdsim.components.Block" title="bdsim.components.Block"><em>Block</em></a><em> or </em><a class="reference internal" href="#bdsim.components.Plug" title="bdsim.components.Plug"><em>Plug</em></a>) – Optional incoming connections</p></li>
<li><p><strong>**kwargs</strong> – Unknow arguments</p></li>
</ul>
</dd>
<dt class="field-even">Returns</dt>
<dd class="field-even"><p>A Block superclass</p>
</dd>
<dt class="field-odd">Return type</dt>
<dd class="field-odd"><p><a class="reference internal" href="#bdsim.components.Block" title="bdsim.components.Block">Block</a></p>
</dd>
</dl>
<p>A block object is the superclass of all blocks in the simulation environment.</p>
<p>This is the top-level initializer, and handles most options passed to
the superclass initializer for each block in the library.</p>
<dl class="method">
<dt id="bdsim.components.Block.__getitem__">
<code class="sig-name descname">__getitem__</code><span class="sig-paren">(</span><em class="sig-param">port</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/bdsim/components.html#Block.__getitem__"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#bdsim.components.Block.__getitem__" title="Permalink to this definition">¶</a></dt>
<dd><p>Convert a block slice reference to a plug.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><p><strong>port</strong> (<em>int</em>) – Port number</p>
</dd>
<dt class="field-even">Returns</dt>
<dd class="field-even"><p>A port plug</p>
</dd>
<dt class="field-odd">Return type</dt>
<dd class="field-odd"><p><a class="reference internal" href="#bdsim.components.Plug" title="bdsim.components.Plug">Plug</a></p>
</dd>
</dl>
<p>Invoked whenever a block is referenced as a slice, for example:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">c</span> <span class="o">=</span> <span class="n">bd</span><span class="o">.</span><span class="n">CONSTANT</span><span class="p">(</span><span class="mi">1</span><span class="p">)</span>

<span class="n">bd</span><span class="o">.</span><span class="n">connect</span><span class="p">(</span><span class="n">x</span><span class="p">,</span> <span class="n">c</span><span class="p">[</span><span class="mi">0</span><span class="p">])</span>
<span class="n">bd</span><span class="o">.</span><span class="n">connect</span><span class="p">(</span><span class="n">c</span><span class="p">[</span><span class="mi">0</span><span class="p">],</span> <span class="n">x</span><span class="p">)</span>
</pre></div>
</div>
<p>In both cases <code class="docutils literal notranslate"><span class="pre">c[0]</span></code> is converted to a <code class="docutils literal notranslate"><span class="pre">Plug</span></code> by this method.</p>
</dd></dl>

<dl class="method">
<dt id="bdsim.components.Block.__mul__">
<code class="sig-name descname">__mul__</code><span class="sig-paren">(</span><em class="sig-param">right</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/bdsim/components.html#Block.__mul__"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#bdsim.components.Block.__mul__" title="Permalink to this definition">¶</a></dt>
<dd><p>Operator for implicit wiring.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>left</strong> (<a class="reference internal" href="#bdsim.components.Block" title="bdsim.components.Block"><em>Block</em></a>) – A block to be wired from</p></li>
<li><p><strong>right</strong> (<a class="reference internal" href="#bdsim.components.Block" title="bdsim.components.Block"><em>Block</em></a><em> or </em><a class="reference internal" href="#bdsim.components.Plug" title="bdsim.components.Plug"><em>Plug</em></a>) – A block or plugto be wired to</p></li>
</ul>
</dd>
<dt class="field-even">Returns</dt>
<dd class="field-even"><p><code class="docutils literal notranslate"><span class="pre">right</span></code></p>
</dd>
<dt class="field-odd">Return type</dt>
<dd class="field-odd"><p><a class="reference internal" href="#bdsim.components.Block" title="bdsim.components.Block">Block</a> or <a class="reference internal" href="#bdsim.components.Plug" title="bdsim.components.Plug">Plug</a></p>
</dd>
</dl>
<p>Implements implicit wiring, for example:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">a</span> <span class="o">=</span> <span class="n">bd</span><span class="o">.</span><span class="n">CONSTANT</span><span class="p">(</span><span class="mi">1</span><span class="p">)</span> <span class="o">*</span> <span class="n">bd</span><span class="o">.</span><span class="n">GAIN</span><span class="p">(</span><span class="mi">2</span><span class="p">)</span>
</pre></div>
</div>
<p>will connect the output of the CONSTANT block to the input of the
GAIN block.  The result will be GAIN block, whose output in this case
will be assigned to <code class="docutils literal notranslate"><span class="pre">a</span></code>.</p>
<p>Note that:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">a</span> <span class="o">=</span> <span class="n">bd</span><span class="o">.</span><span class="n">CONSTANT</span><span class="p">(</span><span class="mi">1</span><span class="p">)</span> <span class="o">*</span> <span class="n">func</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span>
</pre></div>
</div>
<p>will connect port 0 of CONSTANT to port 1 of <code class="docutils literal notranslate"><span class="pre">func</span></code>, and port 1 of <code class="docutils literal notranslate"><span class="pre">func</span></code>
will be assigned to <code class="docutils literal notranslate"><span class="pre">a</span></code>.  To specify a different outport port on <code class="docutils literal notranslate"><span class="pre">func</span></code>
we need to use parentheses:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">a</span> <span class="o">=</span> <span class="p">(</span><span class="n">bd</span><span class="o">.</span><span class="n">CONSTANT</span><span class="p">(</span><span class="mi">1</span><span class="p">)</span> <span class="o">*</span> <span class="n">func</span><span class="p">[</span><span class="mi">1</span><span class="p">])[</span><span class="mi">0</span><span class="p">]</span>
</pre></div>
</div>
<p>which will connect port 0 of CONSTANT ` to port 1 of <code class="docutils literal notranslate"><span class="pre">func</span></code>, and port 0 of <code class="docutils literal notranslate"><span class="pre">func</span></code>
will be assigned to <code class="docutils literal notranslate"><span class="pre">a</span></code>.</p>
<dl class="field-list simple">
<dt class="field-odd">Seealso</dt>
<dd class="field-odd"><p>Plug.__mul__</p>
</dd>
</dl>
</dd></dl>

<dl class="method">
<dt id="bdsim.components.Block.__setattr__">
<code class="sig-name descname">__setattr__</code><span class="sig-paren">(</span><em class="sig-param">name</em>, <em class="sig-param">value</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/bdsim/components.html#Block.__setattr__"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#bdsim.components.Block.__setattr__" title="Permalink to this definition">¶</a></dt>
<dd><p>Convert a LHS block name reference to a wire.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>name</strong> – Port name</p></li>
<li><p><strong>value</strong> (<a class="reference internal" href="#bdsim.components.Block" title="bdsim.components.Block"><em>Block</em></a><em> or </em><a class="reference internal" href="#bdsim.components.Plug" title="bdsim.components.Plug"><em>Plug</em></a>) – the RHS</p></li>
</ul>
</dd>
</dl>
<p>Used to create a wired connection by assignment, for example:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">c</span> <span class="o">=</span> <span class="n">bd</span><span class="o">.</span><span class="n">CONSTANT</span><span class="p">(</span><span class="mi">1</span><span class="p">,</span> <span class="n">inames</span><span class="o">=</span><span class="p">[</span><span class="s1">&#39;u&#39;</span><span class="p">])</span>

<span class="n">c</span><span class="o">.</span><span class="n">u</span> <span class="o">=</span> <span class="n">x</span>
</pre></div>
</div>
<p>Ths method is invoked to create a wire from <code class="docutils literal notranslate"><span class="pre">x</span></code> to port ‘u’ of
the constant block <code class="docutils literal notranslate"><span class="pre">c</span></code>.</p>
<p>Notes:</p>
<blockquote>
<div><ul class="simple">
<li><p>this overloaded method handles all instances of <code class="docutils literal notranslate"><span class="pre">setattr</span></code> and
implements normal functionality as well, only creating a wire
if <code class="docutils literal notranslate"><span class="pre">name</span></code> is a known port name.</p></li>
</ul>
</div></blockquote>
</dd></dl>

<dl class="method">
<dt id="bdsim.components.Block.__setitem__">
<code class="sig-name descname">__setitem__</code><span class="sig-paren">(</span><em class="sig-param">port</em>, <em class="sig-param">src</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/bdsim/components.html#Block.__setitem__"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#bdsim.components.Block.__setitem__" title="Permalink to this definition">¶</a></dt>
<dd><p>Convert a LHS block slice reference to a wire.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>port</strong> (<em>int</em>) – Port number</p></li>
<li><p><strong>src</strong> (<a class="reference internal" href="#bdsim.components.Block" title="bdsim.components.Block"><em>Block</em></a><em> or </em><a class="reference internal" href="#bdsim.components.Plug" title="bdsim.components.Plug"><em>Plug</em></a>) – the RHS</p></li>
</ul>
</dd>
</dl>
<p>Used to create a wired connection by assignment, for example:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">c</span> <span class="o">=</span> <span class="n">bd</span><span class="o">.</span><span class="n">CONSTANT</span><span class="p">(</span><span class="mi">1</span><span class="p">)</span>

<span class="n">c</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> <span class="o">=</span> <span class="n">x</span>
</pre></div>
</div>
<p>Ths method is invoked to create a wire from <code class="docutils literal notranslate"><span class="pre">x</span></code> to port 0 of
the constant block <code class="docutils literal notranslate"><span class="pre">c</span></code>.</p>
</dd></dl>

<dl class="method">
<dt id="bdsim.components.Block.add_inport">
<code class="sig-name descname">add_inport</code><span class="sig-paren">(</span><em class="sig-param">w</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/bdsim/components.html#Block.add_inport"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#bdsim.components.Block.add_inport" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="method">
<dt id="bdsim.components.Block.add_outport">
<code class="sig-name descname">add_outport</code><span class="sig-paren">(</span><em class="sig-param">w</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/bdsim/components.html#Block.add_outport"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#bdsim.components.Block.add_outport" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="method">
<dt id="bdsim.components.Block.check">
<code class="sig-name descname">check</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="_modules/bdsim/components.html#Block.check"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#bdsim.components.Block.check" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="method">
<dt id="bdsim.components.Block.done">
<code class="sig-name descname">done</code><span class="sig-paren">(</span><em class="sig-param">**kwargs</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/bdsim/components.html#Block.done"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#bdsim.components.Block.done" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="method">
<dt id="bdsim.components.Block.info">
<em class="property">property </em><code class="sig-name descname">info</code><a class="headerlink" href="#bdsim.components.Block.info" title="Permalink to this definition">¶</a></dt>
<dd><p>Interactive display of block properties.</p>
<p>Displays all attributes of the block for debugging purposes.</p>
</dd></dl>

<dl class="method">
<dt id="bdsim.components.Block.inport_names">
<code class="sig-name descname">inport_names</code><span class="sig-paren">(</span><em class="sig-param">names</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/bdsim/components.html#Block.inport_names"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#bdsim.components.Block.inport_names" title="Permalink to this definition">¶</a></dt>
<dd><p>Set the names of block input ports.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><p><strong>names</strong> (<em>list of str</em>) – List of port names</p>
</dd>
</dl>
<p>Invoked by the <code class="docutils literal notranslate"><span class="pre">inames</span></code> argument to the Block constructor.</p>
<p>The names can include LaTeX math markup.  The LaTeX version is used
where appropriate, but the port names are a de-LaTeXd version of the
given string with backslash, underscore, caret, braces and dollar signs
removed.</p>
</dd></dl>

<dl class="method">
<dt id="bdsim.components.Block.outport_names">
<code class="sig-name descname">outport_names</code><span class="sig-paren">(</span><em class="sig-param">names</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/bdsim/components.html#Block.outport_names"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#bdsim.components.Block.outport_names" title="Permalink to this definition">¶</a></dt>
<dd><p>Set the names of block output ports.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><p><strong>names</strong> (<em>list of str</em>) – List of port names</p>
</dd>
</dl>
<p>Invoked by the <code class="docutils literal notranslate"><span class="pre">onames</span></code> argument to the Block constructor.</p>
<p>The names can include LaTeX math markup.  The LaTeX version is used
where appropriate, but the port names are a de-LaTeXd version of the
given string with backslash, underscore, caret, braces and dollar signs
removed.</p>
</dd></dl>

<dl class="method">
<dt id="bdsim.components.Block.reset">
<code class="sig-name descname">reset</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="_modules/bdsim/components.html#Block.reset"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#bdsim.components.Block.reset" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="method">
<dt id="bdsim.components.Block.setinput">
<code class="sig-name descname">setinput</code><span class="sig-paren">(</span><em class="sig-param">port</em>, <em class="sig-param">value</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/bdsim/components.html#Block.setinput"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#bdsim.components.Block.setinput" title="Permalink to this definition">¶</a></dt>
<dd><p>Receive input from a wire</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>self</strong> – Block to be updated</p></li>
<li><p><strong>port</strong> (<em>int</em>) – Input port to be updated</p></li>
<li><p><strong>value</strong> – Input value</p></li>
</ul>
</dd>
<dt class="field-even">Returns</dt>
<dd class="field-even"><p>If all inputs have been received</p>
</dd>
<dt class="field-odd">Return type</dt>
<dd class="field-odd"><p>bool</p>
</dd>
</dl>
</dd></dl>

<dl class="method">
<dt id="bdsim.components.Block.setinputs">
<code class="sig-name descname">setinputs</code><span class="sig-paren">(</span><em class="sig-param">*pos</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/bdsim/components.html#Block.setinputs"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#bdsim.components.Block.setinputs" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="method">
<dt id="bdsim.components.Block.sourcename">
<code class="sig-name descname">sourcename</code><span class="sig-paren">(</span><em class="sig-param">port</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/bdsim/components.html#Block.sourcename"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#bdsim.components.Block.sourcename" title="Permalink to this definition">¶</a></dt>
<dd><p>Get the name of output port driving this input port.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><p><strong>port</strong> (<em>int</em>) – Input port</p>
</dd>
<dt class="field-even">Returns</dt>
<dd class="field-even"><p>Port name</p>
</dd>
<dt class="field-odd">Return type</dt>
<dd class="field-odd"><p>str</p>
</dd>
</dl>
<p>Return the name of the output port that drives the specified input
port. The name can be:</p>
<blockquote>
<div><ul class="simple">
<li><p>a LaTeX string if provided</p></li>
<li><p>block name with port number given in square brackets.  The block
name will the one optionally assigned by the user using the <code class="docutils literal notranslate"><span class="pre">name</span></code>
keyword, otherwise a systematic default name.</p></li>
</ul>
</div></blockquote>
<dl class="field-list simple">
<dt class="field-odd">Seealso</dt>
<dd class="field-odd"><p>outport_names</p>
</dd>
</dl>
</dd></dl>

<dl class="method">
<dt id="bdsim.components.Block.start">
<code class="sig-name descname">start</code><span class="sig-paren">(</span><em class="sig-param">**kwargs</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/bdsim/components.html#Block.start"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#bdsim.components.Block.start" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="method">
<dt id="bdsim.components.Block.state_names">
<code class="sig-name descname">state_names</code><span class="sig-paren">(</span><em class="sig-param">names</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/bdsim/components.html#Block.state_names"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#bdsim.components.Block.state_names" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="method">
<dt id="bdsim.components.Block.step">
<code class="sig-name descname">step</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="_modules/bdsim/components.html#Block.step"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#bdsim.components.Block.step" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

</dd></dl>

<dl class="class">
<dt id="bdsim.components.FunctionBlock">
<em class="property">class </em><code class="sig-prename descclassname">bdsim.components.</code><code class="sig-name descname">FunctionBlock</code><span class="sig-paren">(</span><em class="sig-param">**kwargs</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/bdsim/components.html#FunctionBlock"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#bdsim.components.FunctionBlock" title="Permalink to this definition">¶</a></dt>
<dd><p>Bases: <a class="reference internal" href="#bdsim.components.Block" title="bdsim.components.Block"><code class="xref py py-class docutils literal notranslate"><span class="pre">bdsim.components.Block</span></code></a></p>
<p>A FunctionBlock is a subclass of Block that represents a block that has inputs
and outputs but no state variables.  Typically used to describe operations
such as gain, summation or various mappings.</p>
<dl class="attribute">
<dt id="bdsim.components.FunctionBlock.blockclass">
<code class="sig-name descname">blockclass</code><em class="property"> = 'function'</em><a class="headerlink" href="#bdsim.components.FunctionBlock.blockclass" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

</dd></dl>

<dl class="class">
<dt id="bdsim.components.GraphicsBlock">
<em class="property">class </em><code class="sig-prename descclassname">bdsim.components.</code><code class="sig-name descname">GraphicsBlock</code><span class="sig-paren">(</span><em class="sig-param">movie=None</em>, <em class="sig-param">**kwargs</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/bdsim/components.html#GraphicsBlock"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#bdsim.components.GraphicsBlock" title="Permalink to this definition">¶</a></dt>
<dd><p>Bases: <a class="reference internal" href="#bdsim.components.SinkBlock" title="bdsim.components.SinkBlock"><code class="xref py py-class docutils literal notranslate"><span class="pre">bdsim.components.SinkBlock</span></code></a></p>
<p>A GraphicsBlock is a subclass of SinkBlock that represents a block that has inputs
but no outputs. Typically used to save data to a variable, file or
raphics.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>movie</strong> (<em>str</em><em>, </em><em>optional</em>) – Save animation in this file, defaults to None</p></li>
<li><p><strong>**kwargs</strong> – common Block options</p></li>
</ul>
</dd>
<dt class="field-even">Returns</dt>
<dd class="field-even"><p>A PRINT block</p>
</dd>
<dt class="field-odd">Return type</dt>
<dd class="field-odd"><p>Print instance</p>
</dd>
</dl>
<p>The animation is saved as an MP4 video in the specified file.</p>
<dl class="method">
<dt id="bdsim.components.GraphicsBlock.done">
<code class="sig-name descname">done</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="_modules/bdsim/components.html#GraphicsBlock.done"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#bdsim.components.GraphicsBlock.done" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="method">
<dt id="bdsim.components.GraphicsBlock.savefig">
<code class="sig-name descname">savefig</code><span class="sig-paren">(</span><em class="sig-param">fname</em>, <em class="sig-param">**kwargs</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/bdsim/components.html#GraphicsBlock.savefig"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#bdsim.components.GraphicsBlock.savefig" title="Permalink to this definition">¶</a></dt>
<dd><p>Save the figure as an image file</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>fname</strong> (<em>str</em>) – Name of file to save graphics to</p></li>
<li><p><strong>**kwargs</strong> – Options passed to <a class="reference external" href="https://matplotlib.org/3.2.2/api/_as_gen/matplotlib.pyplot.savefig.html">savefig</a></p></li>
</ul>
</dd>
</dl>
<p>The file format is taken from the file extension and can be
jpeg, png or pdf.</p>
</dd></dl>

<dl class="method">
<dt id="bdsim.components.GraphicsBlock.start">
<code class="sig-name descname">start</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="_modules/bdsim/components.html#GraphicsBlock.start"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#bdsim.components.GraphicsBlock.start" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="method">
<dt id="bdsim.components.GraphicsBlock.step">
<code class="sig-name descname">step</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="_modules/bdsim/components.html#GraphicsBlock.step"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#bdsim.components.GraphicsBlock.step" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

</dd></dl>

<dl class="class">
<dt id="bdsim.components.Plug">
<em class="property">class </em><code class="sig-prename descclassname">bdsim.components.</code><code class="sig-name descname">Plug</code><span class="sig-paren">(</span><em class="sig-param">block</em>, <em class="sig-param">port=0</em>, <em class="sig-param">type=None</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/bdsim/components.html#Plug"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#bdsim.components.Plug" title="Permalink to this definition">¶</a></dt>
<dd><p>Bases: <code class="xref py py-class docutils literal notranslate"><span class="pre">object</span></code></p>
<p>Create a plug.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>block</strong> (<a class="reference internal" href="#bdsim.components.Block" title="bdsim.components.Block"><em>Block</em></a>) – The block being plugged into</p></li>
<li><p><strong>port</strong> (<em>int</em><em>, </em><em>optional</em>) – The port on the block, defaults to 0</p></li>
<li><p><strong>type</strong> (<em>str</em><em>, </em><em>optional</em>) – ‘start’ or ‘end’, defaults to None</p></li>
</ul>
</dd>
<dt class="field-even">Returns</dt>
<dd class="field-even"><p>Plug object</p>
</dd>
<dt class="field-odd">Return type</dt>
<dd class="field-odd"><p><a class="reference internal" href="#bdsim.components.Plug" title="bdsim.components.Plug">Plug</a></p>
</dd>
</dl>
<p>Plugs are the interface between a wire and block and have information
about port number and wire end. Plugs are on the end of each wire, and connect a 
Wire to a specific port on a Block.</p>
<dl class="simple">
<dt>The <code class="docutils literal notranslate"><span class="pre">type</span></code> argument indicates if the <code class="docutils literal notranslate"><span class="pre">Plug</span></code> is at:</dt><dd><ul class="simple">
<li><p>the start of a wire, ie. the port is an output port</p></li>
<li><p>the end of a wire, ie. the port is an input port</p></li>
</ul>
</dd>
</dl>
<p>A plug can specify a set of ports on a block.</p>
<dl class="method">
<dt id="bdsim.components.Plug.__mul__">
<code class="sig-name descname">__mul__</code><span class="sig-paren">(</span><em class="sig-param">right</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/bdsim/components.html#Plug.__mul__"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#bdsim.components.Plug.__mul__" title="Permalink to this definition">¶</a></dt>
<dd><p>Operator for implicit wiring.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>left</strong> (<a class="reference internal" href="#bdsim.components.Plug" title="bdsim.components.Plug"><em>Plug</em></a>) – A plug to be wired from</p></li>
<li><p><strong>right</strong> (<a class="reference internal" href="#bdsim.components.Block" title="bdsim.components.Block"><em>Block</em></a><em> or </em><a class="reference internal" href="#bdsim.components.Plug" title="bdsim.components.Plug"><em>Plug</em></a>) – A block or plug to be wired to</p></li>
</ul>
</dd>
<dt class="field-even">Returns</dt>
<dd class="field-even"><p><code class="docutils literal notranslate"><span class="pre">right</span></code></p>
</dd>
<dt class="field-odd">Return type</dt>
<dd class="field-odd"><p><a class="reference internal" href="#bdsim.components.Block" title="bdsim.components.Block">Block</a> or <a class="reference internal" href="#bdsim.components.Plug" title="bdsim.components.Plug">Plug</a></p>
</dd>
</dl>
<p>Implements implicit wiring, where the left-hand operator is a Plug, for example:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">a</span> <span class="o">=</span> <span class="n">bike</span><span class="p">[</span><span class="mi">2</span><span class="p">]</span> <span class="o">*</span> <span class="n">bd</span><span class="o">.</span><span class="n">GAIN</span><span class="p">(</span><span class="mi">3</span><span class="p">)</span>
</pre></div>
</div>
<p>will connect port 2 of <code class="docutils literal notranslate"><span class="pre">bike</span></code> to the input of the GAIN block.</p>
<p>Note that:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">a</span> <span class="o">=</span> <span class="n">bike</span><span class="p">[</span><span class="mi">2</span><span class="p">]</span> <span class="o">*</span> <span class="n">func</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span>
</pre></div>
</div>
<p>will connect port 2 of <code class="docutils literal notranslate"><span class="pre">bike</span></code> to port 1 of <code class="docutils literal notranslate"><span class="pre">func</span></code>, and port 1 of <code class="docutils literal notranslate"><span class="pre">func</span></code>
will be assigned to <code class="docutils literal notranslate"><span class="pre">a</span></code>.  To specify a different outport port on <code class="docutils literal notranslate"><span class="pre">func</span></code>
we need to use parentheses:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">a</span> <span class="o">=</span> <span class="p">(</span><span class="n">bike</span><span class="p">[</span><span class="mi">2</span><span class="p">]</span> <span class="o">*</span> <span class="n">func</span><span class="p">[</span><span class="mi">1</span><span class="p">])[</span><span class="mi">0</span><span class="p">]</span>
</pre></div>
</div>
<p>which will connect port 2 of <code class="docutils literal notranslate"><span class="pre">bike</span></code> to port 1 of <code class="docutils literal notranslate"><span class="pre">func</span></code>, and port 0 of <code class="docutils literal notranslate"><span class="pre">func</span></code>
will be assigned to <code class="docutils literal notranslate"><span class="pre">a</span></code>.</p>
<dl class="field-list simple">
<dt class="field-odd">Seealso</dt>
<dd class="field-odd"><p>Block.__mul__</p>
</dd>
</dl>
</dd></dl>

<dl class="method">
<dt id="bdsim.components.Plug.__setitem__">
<code class="sig-name descname">__setitem__</code><span class="sig-paren">(</span><em class="sig-param">port</em>, <em class="sig-param">src</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/bdsim/components.html#Plug.__setitem__"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#bdsim.components.Plug.__setitem__" title="Permalink to this definition">¶</a></dt>
<dd><p>Convert a LHS block slice reference to a wire.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>port</strong> (<em>int</em>) – Port number</p></li>
<li><p><strong>src</strong> (<a class="reference internal" href="#bdsim.components.Block" title="bdsim.components.Block"><em>Block</em></a><em> or </em><a class="reference internal" href="#bdsim.components.Plug" title="bdsim.components.Plug"><em>Plug</em></a>) – the RHS</p></li>
</ul>
</dd>
</dl>
<p>Used to create a wired connection by assignment, for example:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">c</span> <span class="o">=</span> <span class="n">bd</span><span class="o">.</span><span class="n">CONSTANT</span><span class="p">(</span><span class="mi">1</span><span class="p">)</span>

<span class="n">c</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> <span class="o">=</span> <span class="n">x</span>
</pre></div>
</div>
<p>Ths method is invoked to create a wire from <code class="docutils literal notranslate"><span class="pre">x</span></code> to input port 0 of
the constant block <code class="docutils literal notranslate"><span class="pre">c</span></code>.</p>
</dd></dl>

<dl class="method">
<dt id="bdsim.components.Plug.isslice">
<em class="property">property </em><code class="sig-name descname">isslice</code><a class="headerlink" href="#bdsim.components.Plug.isslice" title="Permalink to this definition">¶</a></dt>
<dd><p>Test if port number is a slice.</p>
<dl class="field-list simple">
<dt class="field-odd">Returns</dt>
<dd class="field-odd"><p>Whether the port is a slice</p>
</dd>
<dt class="field-even">Return type</dt>
<dd class="field-even"><p>bool</p>
</dd>
</dl>
<p>Returns <code class="docutils literal notranslate"><span class="pre">True</span></code> if the port is a slice, eg. <code class="docutils literal notranslate"><span class="pre">[0:3]</span></code>, and <code class="docutils literal notranslate"><span class="pre">False</span></code>
for a simple index, eg. <code class="docutils literal notranslate"><span class="pre">[2]</span></code>.</p>
</dd></dl>

<dl class="method">
<dt id="bdsim.components.Plug.portlist">
<em class="property">property </em><code class="sig-name descname">portlist</code><a class="headerlink" href="#bdsim.components.Plug.portlist" title="Permalink to this definition">¶</a></dt>
<dd><p>Return port numbers.</p>
<dl class="field-list simple">
<dt class="field-odd">Returns</dt>
<dd class="field-odd"><p>Port numbers</p>
</dd>
<dt class="field-even">Return type</dt>
<dd class="field-even"><p>int or list of int</p>
</dd>
</dl>
<p>If the port is a simple index, eg. <code class="docutils literal notranslate"><span class="pre">[2]</span></code> returns 2.</p>
<p>If the port is a slice, eg. <code class="docutils literal notranslate"><span class="pre">[0:3]</span></code>, returns [0, 1, 2].</p>
</dd></dl>

<dl class="method">
<dt id="bdsim.components.Plug.width">
<em class="property">property </em><code class="sig-name descname">width</code><a class="headerlink" href="#bdsim.components.Plug.width" title="Permalink to this definition">¶</a></dt>
<dd><p>Return number of ports connected.</p>
<dl class="field-list simple">
<dt class="field-odd">Returns</dt>
<dd class="field-odd"><p>Number of ports</p>
</dd>
<dt class="field-even">Return type</dt>
<dd class="field-even"><p>int</p>
</dd>
</dl>
<p>If the port is a simple index, eg. <code class="docutils literal notranslate"><span class="pre">[2]</span></code> returns 1.</p>
<p>If the port is a slice, eg. <code class="docutils literal notranslate"><span class="pre">[0:3]</span></code>, returns 3.</p>
</dd></dl>

</dd></dl>

<dl class="class">
<dt id="bdsim.components.SinkBlock">
<em class="property">class </em><code class="sig-prename descclassname">bdsim.components.</code><code class="sig-name descname">SinkBlock</code><span class="sig-paren">(</span><em class="sig-param">**kwargs</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/bdsim/components.html#SinkBlock"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#bdsim.components.SinkBlock" title="Permalink to this definition">¶</a></dt>
<dd><p>Bases: <a class="reference internal" href="#bdsim.components.Block" title="bdsim.components.Block"><code class="xref py py-class docutils literal notranslate"><span class="pre">bdsim.components.Block</span></code></a></p>
<p>A SinkBlock is a subclass of Block that represents a block that has inputs
but no outputs. Typically used to save data to a variable, file or 
graphics.</p>
<dl class="attribute">
<dt id="bdsim.components.SinkBlock.blockclass">
<code class="sig-name descname">blockclass</code><em class="property"> = 'sink'</em><a class="headerlink" href="#bdsim.components.SinkBlock.blockclass" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

</dd></dl>

<dl class="class">
<dt id="bdsim.components.SourceBlock">
<em class="property">class </em><code class="sig-prename descclassname">bdsim.components.</code><code class="sig-name descname">SourceBlock</code><span class="sig-paren">(</span><em class="sig-param">**kwargs</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/bdsim/components.html#SourceBlock"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#bdsim.components.SourceBlock" title="Permalink to this definition">¶</a></dt>
<dd><p>Bases: <a class="reference internal" href="#bdsim.components.Block" title="bdsim.components.Block"><code class="xref py py-class docutils literal notranslate"><span class="pre">bdsim.components.Block</span></code></a></p>
<p>A SourceBlock is a subclass of Block that represents a block that has outputs
but no inputs.  Its output is a function of parameters and time.</p>
<dl class="attribute">
<dt id="bdsim.components.SourceBlock.blockclass">
<code class="sig-name descname">blockclass</code><em class="property"> = 'source'</em><a class="headerlink" href="#bdsim.components.SourceBlock.blockclass" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

</dd></dl>

<dl class="class">
<dt id="bdsim.components.Struct">
<em class="property">class </em><code class="sig-prename descclassname">bdsim.components.</code><code class="sig-name descname">Struct</code><span class="sig-paren">(</span><em class="sig-param">name='Struct'</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/bdsim/components.html#Struct"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#bdsim.components.Struct" title="Permalink to this definition">¶</a></dt>
<dd><p>Bases: <code class="xref py py-class docutils literal notranslate"><span class="pre">collections.UserDict</span></code></p>
<p>A dict like object that allows items to be added by attribute or by key.</p>
<p>For example:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">d</span> <span class="o">=</span> <span class="n">Struct</span><span class="p">(</span><span class="s1">&#39;thing&#39;</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">d</span><span class="o">.</span><span class="n">a</span> <span class="o">=</span> <span class="mi">1</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">d</span><span class="p">[</span><span class="s1">&#39;b&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="mi">2</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">d</span><span class="o">.</span><span class="n">a</span>
<span class="go">1</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">d</span><span class="p">[</span><span class="s1">&#39;a&#39;</span><span class="p">]</span>
<span class="go">1</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">d</span><span class="o">.</span><span class="n">b</span>
<span class="go">2</span>
<span class="gp">&gt;&gt;&gt; </span><span class="nb">str</span><span class="p">(</span><span class="n">d</span><span class="p">)</span>
<span class="go">&quot;thing {&#39;a&#39;: 1, &#39;b&#39;: 2}&quot;</span>
</pre></div>
</div>
<dl class="method">
<dt id="bdsim.components.Struct.__getattr__">
<code class="sig-name descname">__getattr__</code><span class="sig-paren">(</span><em class="sig-param">name</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/bdsim/components.html#Struct.__getattr__"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#bdsim.components.Struct.__getattr__" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="method">
<dt id="bdsim.components.Struct.__setattr__">
<code class="sig-name descname">__setattr__</code><span class="sig-paren">(</span><em class="sig-param">name</em>, <em class="sig-param">value</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/bdsim/components.html#Struct.__setattr__"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#bdsim.components.Struct.__setattr__" title="Permalink to this definition">¶</a></dt>
<dd><p>Implement setattr(self, name, value).</p>
</dd></dl>

</dd></dl>

<dl class="class">
<dt id="bdsim.components.SubsystemBlock">
<em class="property">class </em><code class="sig-prename descclassname">bdsim.components.</code><code class="sig-name descname">SubsystemBlock</code><span class="sig-paren">(</span><em class="sig-param">**kwargs</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/bdsim/components.html#SubsystemBlock"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#bdsim.components.SubsystemBlock" title="Permalink to this definition">¶</a></dt>
<dd><p>Bases: <a class="reference internal" href="#bdsim.components.Block" title="bdsim.components.Block"><code class="xref py py-class docutils literal notranslate"><span class="pre">bdsim.components.Block</span></code></a></p>
<p>A Function is a subclass of Block that represents a block that has inputs
and outputs but no state variables.  Typically used to describe operations
such as gain, summation or various mappings.</p>
<dl class="attribute">
<dt id="bdsim.components.SubsystemBlock.blockclass">
<code class="sig-name descname">blockclass</code><em class="property"> = 'subsystem'</em><a class="headerlink" href="#bdsim.components.SubsystemBlock.blockclass" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

</dd></dl>

<dl class="class">
<dt id="bdsim.components.TransferBlock">
<em class="property">class </em><code class="sig-prename descclassname">bdsim.components.</code><code class="sig-name descname">TransferBlock</code><span class="sig-paren">(</span><em class="sig-param">**kwargs</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/bdsim/components.html#TransferBlock"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#bdsim.components.TransferBlock" title="Permalink to this definition">¶</a></dt>
<dd><p>Bases: <a class="reference internal" href="#bdsim.components.Block" title="bdsim.components.Block"><code class="xref py py-class docutils literal notranslate"><span class="pre">bdsim.components.Block</span></code></a></p>
<p>A TransferBlock is a subclass of Block that represents a block with inputs
outputs and states. Typically used to describe a continuous time dynamic
system, either linear or nonlinear.</p>
<dl class="attribute">
<dt id="bdsim.components.TransferBlock.blockclass">
<code class="sig-name descname">blockclass</code><em class="property"> = 'transfer'</em><a class="headerlink" href="#bdsim.components.TransferBlock.blockclass" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="method">
<dt id="bdsim.components.TransferBlock.check">
<code class="sig-name descname">check</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="_modules/bdsim/components.html#TransferBlock.check"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#bdsim.components.TransferBlock.check" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="method">
<dt id="bdsim.components.TransferBlock.getstate">
<code class="sig-name descname">getstate</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="_modules/bdsim/components.html#TransferBlock.getstate"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#bdsim.components.TransferBlock.getstate" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="method">
<dt id="bdsim.components.TransferBlock.reset">
<code class="sig-name descname">reset</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="_modules/bdsim/components.html#TransferBlock.reset"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#bdsim.components.TransferBlock.reset" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="method">
<dt id="bdsim.components.TransferBlock.setstate">
<code class="sig-name descname">setstate</code><span class="sig-paren">(</span><em class="sig-param">x</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/bdsim/components.html#TransferBlock.setstate"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#bdsim.components.TransferBlock.setstate" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

</dd></dl>

<dl class="class">
<dt id="bdsim.components.Wire">
<em class="property">class </em><code class="sig-prename descclassname">bdsim.components.</code><code class="sig-name descname">Wire</code><span class="sig-paren">(</span><em class="sig-param">start=None</em>, <em class="sig-param">end=None</em>, <em class="sig-param">name=None</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/bdsim/components.html#Wire"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#bdsim.components.Wire" title="Permalink to this definition">¶</a></dt>
<dd><p>Bases: <code class="xref py py-class docutils literal notranslate"><span class="pre">object</span></code></p>
<p>Create a wire.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>start</strong> (<a class="reference internal" href="#bdsim.components.Plug" title="bdsim.components.Plug"><em>Plug</em></a><em>, </em><em>optional</em>) – Plug at the start of a wire, defaults to None</p></li>
<li><p><strong>end</strong> (<a class="reference internal" href="#bdsim.components.Plug" title="bdsim.components.Plug"><em>Plug</em></a><em>, </em><em>optional</em>) – Plug at the end of a wire, defaults to None</p></li>
<li><p><strong>name</strong> (<em>str</em><em>, </em><em>optional</em>) – Name of wire, defaults to None</p></li>
</ul>
</dd>
<dt class="field-even">Returns</dt>
<dd class="field-even"><p>A wire object</p>
</dd>
<dt class="field-odd">Return type</dt>
<dd class="field-odd"><p><a class="reference internal" href="#bdsim.components.Wire" title="bdsim.components.Wire">Wire</a></p>
</dd>
</dl>
<p>A Wire object connects two block ports.  A Wire has a reference to the
start and end ports.</p>
<p>A wire records all the connections defined by the user.  At compile time
wires are used to build inter-block references.</p>
<p>Between two blocks, a wire can connect one or more ports, ie. it can connect
a set of output ports on one block to a same sized set of input ports on 
another block.</p>
<dl class="method">
<dt id="bdsim.components.Wire.fullname">
<em class="property">property </em><code class="sig-name descname">fullname</code><a class="headerlink" href="#bdsim.components.Wire.fullname" title="Permalink to this definition">¶</a></dt>
<dd><p>Display wire connection details.</p>
<dl class="field-list simple">
<dt class="field-odd">Returns</dt>
<dd class="field-odd"><p>Wire name</p>
</dd>
<dt class="field-even">Return type</dt>
<dd class="field-even"><p>str</p>
</dd>
</dl>
<p>String format:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">d2goal</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> <span class="o">--&gt;</span> <span class="n">Kv</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span>
</pre></div>
</div>
</dd></dl>

<dl class="method">
<dt id="bdsim.components.Wire.info">
<em class="property">property </em><code class="sig-name descname">info</code><a class="headerlink" href="#bdsim.components.Wire.info" title="Permalink to this definition">¶</a></dt>
<dd><p>Interactive display of wire properties.</p>
<p>Displays all attributes of the wire for debugging purposes.</p>
</dd></dl>

<dl class="method">
<dt id="bdsim.components.Wire.send">
<code class="sig-name descname">send</code><span class="sig-paren">(</span><em class="sig-param">value</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/bdsim/components.html#Wire.send"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#bdsim.components.Wire.send" title="Permalink to this definition">¶</a></dt>
<dd><p>Send a value to the port at end of this wire.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><p><strong>value</strong> (<em>float</em><em>, </em><em>numpy.ndarray</em><em>, </em><em>etc.</em>) – A port value</p>
</dd>
</dl>
<p>The value is sent to the input port connected to the end of this wire.</p>
</dd></dl>

</dd></dl>

<dl class="function">
<dt id="bdsim.components.block">
<code class="sig-prename descclassname">bdsim.components.</code><code class="sig-name descname">block</code><span class="sig-paren">(</span><em class="sig-param">cls</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/bdsim/components.html#block"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#bdsim.components.block" title="Permalink to this definition">¶</a></dt>
<dd><p>Decorator for block classes</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><p><strong>cls</strong> (<em>subclass of Block</em>) – A block to be registered for the simulator</p>
</dd>
<dt class="field-even">Returns</dt>
<dd class="field-even"><p>the class</p>
</dd>
<dt class="field-odd">Return type</dt>
<dd class="field-odd"><p>subclass of Block</p>
</dd>
</dl>
<p>&#64;block
class MyBlock:</p>
<p>The modules in <code class="docutils literal notranslate"><span class="pre">./blocks</span></code> uses the <code class="docutils literal notranslate"><span class="pre">block</span></code> decorator to declare
that they are a block which will be made available as a method of the
<code class="docutils literal notranslate"><span class="pre">BlockDiagram</span></code> instance.  The method name is a capitalized version of
the class name.</p>
</dd></dl>

</div>
</div>


          </div>
          
        </div>
      </div>
      <div class="sphinxsidebar" role="navigation" aria-label="main navigation">
        <div class="sphinxsidebarwrapper">
<h1 class="logo"><a href="index.html">Block diagram simulation</a></h1>








<h3>Navigation</h3>
<p class="caption"><span class="caption-text">Code documentation:</span></p>
<ul class="current">
<li class="toctree-l1 current"><a class="current reference internal" href="#">bdsim package</a><ul>
<li class="toctree-l2"><a class="reference internal" href="#module-bdsim.blockdiagram">BlockDiagram class</a></li>
<li class="toctree-l2"><a class="reference internal" href="#components">Components</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="bdsim.blocks.html">Blocks</a></li>
</ul>

<div class="relations">
<h3>Related Topics</h3>
<ul>
  <li><a href="index.html">Documentation overview</a><ul>
      <li>Previous: <a href="index.html" title="previous chapter">Block diagram simulator</a></li>
      <li>Next: <a href="bdsim.blocks.html" title="next chapter">Blocks</a></li>
  </ul></li>
</ul>
</div>
<div id="searchbox" style="display: none" role="search">
  <h3 id="searchlabel">Quick search</h3>
    <div class="searchformwrapper">
    <form class="search" action="search.html" method="get">
      <input type="text" name="q" aria-labelledby="searchlabel" />
      <input type="submit" value="Go" />
    </form>
    </div>
</div>
<script>$('#searchbox').show(0);</script>








        </div>
      </div>
      <div class="clearer"></div>
    </div>
    <div class="footer">
      &copy;2020, Peter Corke.
      
      |
      Powered by <a href="http://sphinx-doc.org/">Sphinx 2.4.4</a>
      &amp; <a href="https://github.com/bitprophet/alabaster">Alabaster 0.7.12</a>
      
      |
      <a href="_sources/bdsim.rst.txt"
          rel="nofollow">Page source</a>
    </div>

    

    
  </body>
</html>